package com.home.cop.sysinfo.controller;

import com.home.cop.base.BaseController;
import com.home.cop.sysinfo.service.RegionService;
import com.home.cop.system.RequiredAuth;
import com.home.cop.system.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/region")
@Api("行政区域相关")
public class RegionController extends BaseController {


    @Autowired
    private RegionService regionService;

    @RequiredAuth
    @PostMapping("/list")
    @ApiOperation(value = "行政区域列表", notes = "根据编号获取行政区域列表")
    @ApiImplicitParams({ @ApiImplicitParam(name = "regionId", value = "编号", required = false, dataType = "String", paramType = "query")
    })
    public Result list(@RequestParam(value = "regionId",required = false) String regionId){
        return Result.returnSuccess().setData(regionService.list(regionId));
    }


    @RequiredAuth
    @PostMapping("/tree")
    @ApiOperation(value = "行政区域列表", notes = "根据编号获取行政区域列表")
    public Result regionTree(){
        return Result.returnSuccess().setData(regionService.regionTree());
    }
}
